#include "study.h"
#include "ui_study.h"
#include <QPainter>
#include <QFont>
#include <QPixmap>
#include <QTimer>

int i2=1;

study::study(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::study)
{
    ui->setupUi(this);
}

void study::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setPen(Qt::black);//设置画笔颜色
    painter.setBrush(Qt::black);//设置填充颜色
    painter.drawRect(0,0,480,480);
    int x1=ui->qhframe->pos().x();
    int y1=ui->qhframe->pos().y();
    qh[0].load(":/resourse/0.png") ;
    qh[1].load(":/resourse/1.png") ;
    qh[2].load(":/resourse/2.png") ;
    qh[3].load(":/resourse/3.png") ;
    qh[4].load(":/resourse/4.png") ;
    qh[5].load(":/resourse/5.png") ;
    qh[6].load(":/resourse/6.png") ;
    qh[7].load(":/resourse/7.png") ;
    qh[8].load(":/resourse/8.png") ;
    qh[9].load(":/resourse/9.png") ;
    qh[10].load(":/resourse/10.png") ;
    qh[11].load(":/resourse/p1.png") ;
    qh[12].load(":/resourse/12.png") ;
    qh[13].load(":/resourse/13.png") ;
    qh[14].load(":/resourse/14.png") ;
    QFont font1("Courier New",10);
    painter.setFont(font1);
    painter.setPen(Qt::red);
    painter.setBrush(Qt::red);
    painter.drawText(10,185,dialog[i2]);

    if (i2==1)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[4]);
    }

    if (i2==2)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[3]);
    }

    if (i2==3||i2==4)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[5]);
    }

    if (i2==5)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[12]);
    }

    if (i2==6||i2==7)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[6]);
    }

    if (i2==8)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }

    if (i2==9)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[5]);
    }

    if (i2==10)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[10]);
    }

    if (i2==11)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[9]);
    }

    if (i2==12)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[6]);
    }

    if (i2==13)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[13]);
    }

    if (i2==14)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[14]);
    }

    if (i2==15)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[7]);
    }

    if (i2==16)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[10]);
    }

    if (i2==17)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[6]);
    }

    if (i2==18)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[9]);
    }

    if (i2==19)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }

    if (i2==20)
    {
        this->close();
        Game2 *g2 =new Game2();
        g2->show();
    }

}

void study::on_nextpushButton_clicked()
{
    i2++;
    update();
}

study::~study()
{
    delete ui;
}
